﻿using System.IO;
using SevenZip.Compression.LZMA;

class LzmaCompression
{
    private const string INPUT_FILE_NAME = @"..\..\..\LzmaCompression\test.bin";
    private const string ARCHIVE_FILE_NAME = @"..\..\..\LzmaCompression\test.7z";

    static void Encode()
    {
        Encoder enc = new Encoder();

        FileStream input = new FileStream(INPUT_FILE_NAME, FileMode.Open, FileAccess.Read);
        FileStream output = new FileStream(ARCHIVE_FILE_NAME, FileMode.OpenOrCreate, FileAccess.Write);
        using (input)
        {
            using (output)
            {
                enc.Code(input, output, -1, -1, new State(-1, -1));
            }
        }
    }

    static void Decode()
    {
        SevenZip.Compression.LZMA.Decoder dec = new SevenZip.Compression.LZMA.Decoder();
        FileStream input = new FileStream(ARCHIVE_FILE_NAME, FileMode.Open, FileAccess.Read);
        FileStream output = new FileStream(INPUT_FILE_NAME + "(2)", FileMode.OpenOrCreate, FileAccess.Write);
        using (input)
        {
            using (output)
            {
                dec.Code(input, output, -1, -1, new State(-1, -1));
            }
        }
    }

    static void Main(string[] args)
    {

        Encode();
        //Decode();

        //SevenZip.Compression.LZMA.Decoder dec = new SevenZip.Compression.LZMA.Decoder();
        //dec.
    }
}
